Skip to main content

import from_xlsx

Turn a xlsx file to i18n file(s)

Command

# Display help for import from_xlsx
npx @jy95/i18n-tools import from_xlsx --help

Purpose

Suppose you have a xlsx file structured as :

xlsx file

This command helps you to turn this into several i18n json files :

fr.json
{
"commons":{
"myNestedKey":"Hello world FR",
"myNestedArray":[
"1 FR",
"2 FR",
"3 FR"
]
},
"array":[
"1 FR",
"2 FR",
"3 FR"
],
"simpleKey":"[FR] not setted key",
"Key with spaces":[
{
"test":"42 is the answer"
}
],
"Missing key in DE":"present"
}

Examples of settings

npx @jy95/i18n-tools import from_xlsx --settings "/absolutePath/to/settings1.json"
settings1.json
{
"input":"D:\\workspace\\i18n-tools\\test\\fixtures\\import-xlsx\\export-xlsx.xlsx",
"columns":"D:\\TEMP\\TEMP\\tests-for-import\\correct\\columns.json",
"locales":[
"FR",
"NL",
"DE"
],
"outputDir":"D:\\TEMP\\TEMP\\tests-for-import",
"suffix":"_settings1"
}
columns.json
{
"technical_key":"Technical Key",
"locales":{
"FR":"French translation",
"NL":"Dutch translation",
"DE":"German translation"
}
}

FAQ

I want as result flat JSON file(s). How can I achieve that ?

Simply set option keySeparator to false in your settings.json or settings.js, such as :

settings.json
{
"keySeparator": false
}